﻿using System;
using System.IO;
using System.Runtime.Serialization;
using System.Windows.Media;
using System.Windows.Media.Media3D;

namespace GameBoard
{
    [DataContract]
    [KnownType(typeof(BaseTerrainData))]
    [KnownType(typeof(ArrowVisualData))]
    [KnownType(typeof(GridVisualData))]
    [KnownType(typeof(InfoTextVisualData))]
    [KnownType(typeof(MovementCircleVisualData))]
    [KnownType(typeof(PictureVisualData))]
    public abstract class BaseVisualData
    {
        [DataMember]
        public Guid FactoryID { get; set; }

        [DataMember]
        public Color MaterialColor { get; set; }

        [DataMember]
        public string MaterialFile { get; set; }
        [DataMember]
        public string ObjectFile { get; set; }

        [DataMember]
        internal bool BelongsToMoveablePicture { get; set; }

        public virtual Material Material 
        {
            get
            {
                if (!string.IsNullOrWhiteSpace(MaterialFile))
                {
                    if (File.Exists(MaterialFile))
                    {
                        var imageBrush = MaterialMaker.MakeImageMaterial(MaterialFile);
                        return new DiffuseMaterial(imageBrush);
                    }
                }
                return new DiffuseMaterial(new SolidColorBrush(MaterialColor));
            }
        }


        
    }
}